﻿// -------------------------------------------------------------------------
//    @FileName         :    NFSnsFriendModule.cpp
//    @Author           :    gaoyi
//    @Date             :    2025-03-31
//    @Email			:    445267987@qq.com
//    @Module           :    NFSnsFriendModule
//
// -------------------------------------------------------------------------

#include "NFSnsFriendModule.h"

#include "proto_svr_common.pb.h"
#include "proto_svr_sns.pb.h"

NFSnsFriendModule::NFSnsFriendModule(NFIPluginManager* p):NFMMODynamicModule(p)
{
}

NFSnsFriendModule::~NFSnsFriendModule()
{
}

int NFSnsFriendModule::Awake()
{
    RegisterServerMessage(NF_ST_SNS_SERVER, proto_ff::E_GS_FRIEND_QUERY_REQ);
    RegisterServerMessage(NF_ST_SNS_SERVER, proto_ff::E_GS_FRIEND_OPERATE_REQ);
    RegisterServerMessage(NF_ST_SNS_SERVER, proto_ff::E_GS_FRIEND_RECOMMEND_REQ);
    RegisterServerMessage(NF_ST_SNS_SERVER, proto_ff::E_GS_FRIEND_1V1_INVITE_REQ);
    RegisterServerMessage(NF_ST_SNS_SERVER, proto_ff::E_GS_FRIEND_NOT_RECOMMAND_REQ);
    RegisterServerMessage(NF_ST_SNS_SERVER, proto_ff::E_GS_FRIEND_ADD_DEGREE_NTF);
    RegisterServerMessage(NF_ST_SNS_SERVER, proto_ff::E_GS_GET_FRIEND_DEGREE_REQ);
    RegisterServerMessage(NF_ST_SNS_SERVER, proto_ff::E_GS_SEND_FLOWER_REQ);
    return 0;
}

int NFSnsFriendModule::OnExecute(uint32_t serverType, uint32_t nEventID, uint32_t bySrcType, uint64_t nSrcID, const google::protobuf::Message* pMessage)
{
    return 0;
}

int NFSnsFriendModule::OnHandleServerMessage(uint64_t unLinkId, NFDataPackage& packet)
{
    if (!m_pObjPluginManager->IsInited(NF_ST_SNS_SERVER))
    {
        NFLogError(NF_LOG_DEFAULT, packet.nParam1, "Sns Server not inited, drop client msg:{}", packet.ToString());
        return -1;
    }

    if (m_pObjPluginManager->IsServerStopping())
    {
        NFLogError(NF_LOG_DEFAULT, packet.nParam1, "Sns Server is Stopping, drop client msg:{}", packet.ToString());
        return -1;
    }

    int iRetCode = 0;
    switch (packet.nMsgId)
    {
        case proto_ff::E_GS_FRIEND_QUERY_REQ:
        {
            iRetCode = OnHandleFriendQueryReq(unLinkId, packet);
            break;
        }
        default:
        {
            NFLogError(NF_LOG_DEFAULT, 0, "Server MsgId:{} Register, But Not Handle, Package:{}", packet.nMsgId, packet.ToString());
            break;
        }
    }
    return iRetCode;
}

int NFSnsFriendModule::OnHandleFriendQueryReq(uint64_t unLinkId, NFDataPackage& packet)
{
    proto_ff::Proto_GSLoginReq req;
    CLIENT_MSG_PROCESS_WITH_PRINTF(packet, req);

    return 0;
}
